package cn.iocoder.yudao.module.operation.dal.mysql.log;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.operation.dal.dataobject.log.LogDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.operation.controller.admin.log.vo.*;

/**
 * 操作日志 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface LogMapper extends BaseMapperX<LogDO> {

    default PageResult<LogDO> selectPage(LogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<LogDO>()
                .betweenIfPresent(LogDO::getOperateTime, reqVO.getOperateTime())
                .eqIfPresent(LogDO::getUserId, reqVO.getUserId())
                .likeIfPresent(LogDO::getUserName, reqVO.getUserName())
                .eqIfPresent(LogDO::getUserIp, reqVO.getUserIp())
                .eqIfPresent(LogDO::getUserAgent, reqVO.getUserAgent())
                .eqIfPresent(LogDO::getContentTitle, reqVO.getContentTitle())
                .eqIfPresent(LogDO::getContent, reqVO.getContent())
                .orderByDesc(LogDO::getId));
    }

}